package com.yinxin.reflection.InvocationProxy.normal;

import com.yinxin.reflection.InvocationProxy.Jdk.UserDao;
import com.yinxin.reflection.InvocationProxy.Jdk.UserDaoImpl;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Properties;

/**
 * @author yinxin
 * @version 1.0
 * @Description:
 * @date 2022/8/1816:16
 */
public class MybatisApplication {
    //Test
    /*public static void main(String[] args) throws Exception {
        UserDao userDao = new UserDaoImpl();
        Object instance = Class.forName(Test.class.getName()).newInstance();
        Method sayHell = instance.getClass().getMethod("sayHello", String.class);
        sayHell.invoke(instance, "hello");
    }*/
    //Test2
    public static void main(String[] args) throws Exception {
        Properties properties = new Properties();
        properties.load(new FileReader("src/main/resources/class.txt"));
        System.out.println(properties);
        String className = properties.getProperty("class");
        String methodName = properties.getProperty("method");
        Class<?> forName = Class.forName(className);
        Method method = forName.getMethod(methodName);
        method.invoke(forName.newInstance());
    }
}
